import java.util.*;

/**
 * @author LKQ
 * @date 2022/4/2 21:34
 * @description 假设行为降序，列为升序，那么从左上角或右下角开始遍历
 */
public class Solution3 {
    public static void main(String[] args) {

    }
    public boolean searchMatrix(int[][] matrix, int target) {
        int m = matrix.length, n = matrix[0].length;
        int x = m - 1, y = n - 1;
        while (x >= 0 && y >= 0) {
            int t = matrix[x][y];
            if (t == target) {
                return true;
            } else if (t > target) {
                x--;
            } else {
                y--;
            }
        }

        return false;
    }
}
